package section6_6;

import java.util.concurrent.ConcurrentSkipListMap;

/**
 * Created by Hyman on 2017/6/15.
 */
public class Task implements Runnable {

    /**
     * 任务编号
     */
    private String id;
    /**
     * 存储联系人的可遍历的映射
     */
    private ConcurrentSkipListMap<String, Contact> map;

    public Task(String id, ConcurrentSkipListMap<String, Contact> map) {
        this.id = id;
        this.map = map;
    }

    /**
     * 核心方法，产生1000个联系人，并且交它们存储在一个可遍历的映射中
     */
    @Override
    public void run() {
        for(int i=0; i<1000; i++) {
            Contact contact = new Contact(id, String.valueOf(i + 1000));
            map.put(id+contact.getPhone(), contact);
        }

    }
}
